﻿using System;
using System . Collections . Generic;
using System . Linq;
using System . Text;
using System . Threading . Tasks;
using System . Reflection;

namespace WenceyWang . RichMan4L . Cards
{

	public abstract class Card
	{
		public CardStatus Status { get; protected set; }

		public abstract long PriceWhenBuy { get; set; }

		public abstract long PriceWhenSell { get; set; }

		public abstract void Use ( );

		List<Type> cards = null;

		public Task LoadCards ( )
		{
			Task loadTask = new Task ( ( ) =>
			{
				foreach ( var item in Assembly . GetExecutingAssembly ( ) . GetTypes ( ) )
				{
					if ( typeof ( Card ) . IsAssignableFrom ( item ) || ( !item . IsAbstract ) )
					{
						cards . Add ( item );
					}
				}
			} );

			loadTask . Start ( );

			return loadTask;

		}

		public List<Type> Cards
		{
			get
			{
				if ( cards == null )
				{
					LoadCards ( ) . Wait ( );
				}
				return cards;
			}
		}


	}



}
